/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.cadi.games;

import com.cadi.aux.Clickable;
import com.cadi.aux.Selector;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import javax.swing.ImageIcon;
import javax.swing.JLabel;
import javax.swing.JLayeredPane;


/**
 *
 * @author Luis Eduardo Garay Buenrostro
 */
public class CoinSelector extends Selector{
    private JLabel background;
    public CoinSelector(boolean condition){
        super();
        if(condition){
            voiceFirst();
        }
        toMenu.setVisible(true);
        currentLevel = 1;
        toNextLevel = new MouseAdapter() {
            @Override
            public void mouseClicked(MouseEvent evt){
                switch(currentLevel){
                    case 1:
                        setLevelTwoEasy();
                        currentLevel++;
                        break;
                    case 2:
                        setLevelThreeEasy();
                        currentLevel++;
                        break;
                    case 3:
                        setLevelFourEasy();
                        currentLevel++;
                        break;
                    case 4:
                        setLevelFiveEasy();
                        currentLevel++;
                        break;
                    case 5:
                        BillSelector next = new BillSelector(true);
                        window.setVisible(false);
                        break;
                    case 11:
                        setLevelTwoHard();
                        currentLevel++;
                        break;
                    case 12:
                        setLevelThreeHard();
                        currentLevel++;
                        break;
                    case 13:
                        setLevelFourHard();
                        currentLevel++;
                        break;
                    case 14:
                        setLevelFiveHard();
                        currentLevel++;
                        break;
                    case 15:
                        BillSelector nextHard = new BillSelector(false);
                        nextHard.setLevelOneHard();
                        window.setVisible(false);
                }
                
            }};
        instructions = new JLabel(new ImageIcon(getClass().getResource("/resources/coin_instruction.png")));
        instructions.setBounds(150, 300, 200, 162);
        container.add(instructions, JLayeredPane.PALETTE_LAYER);
        topLeftObject = new Clickable(new ImageIcon(getClass().getResource("/resources/sol.png")));
        topLeftObject.setBounds(300, 70,200,200);
        container.add(topLeftObject, JLayeredPane.PALETTE_LAYER);
        bottomRightObject = new Clickable(new ImageIcon(getClass().getResource("/resources/5pesos-big.png")));
        bottomRightObject.setBounds(900,300 , 205, 208);
        bottomRightObject.setGoal(true);
        bottomRightObject.addMouseListener(toNextLevel);
        container.add(bottomRightObject, JLayeredPane.PALETTE_LAYER);
        bottomLeftObject = new Clickable(new ImageIcon(getClass().getResource("/resources/tuerca.png")));
        bottomLeftObject.setBounds(500,400, 100, 100);
        container.add(bottomLeftObject, JLayeredPane.PALETTE_LAYER);
        topRightObject = new Clickable(new ImageIcon(getClass().getResource("/resources/corcholata.png")));
        topRightObject.setBounds(600,150, 233, 222);
        container.add(topRightObject, JLayeredPane.PALETTE_LAYER);
        background = new JLabel(new ImageIcon(getClass().getResource("/resources/fondo3.png")));
        background.setBounds(0, 0, 1280,800);
         container.add(background, JLayeredPane.PALETTE_LAYER);
        window.setVisible(true);
        
    }
    
    public void setLevelTwoEasy(){
        bottomRightObject.removeMouseListener(toNextLevel);
        topRightObject.setIcon(new ImageIcon(getClass().getResource("/resources/2pesos-big.png")));
        topRightObject.setGoal(true);
        topRightObject.addMouseListener(toNextLevel);
        bottomRightObject.setIcon(new ImageIcon(getClass().getResource("/resources/tuerca2.png")));
        topLeftObject.setIcon(new ImageIcon(getClass().getResource("/resources/tornillo.png")));
        bottomLeftObject.setIcon(new ImageIcon(getClass().getResource("/resources/corcholata2.png")));
        bottomLeftObject.setBounds(500, 400, 204, 166);
        window.repaint();
        voice.play();
    }
    
    public void setLevelThreeEasy(){
        topRightObject.removeMouseListener(toNextLevel);
        topRightObject.setIcon(new ImageIcon(getClass().getResource("/resources/tornillo.png")));
        bottomRightObject.setIcon(new ImageIcon(getClass().getResource("/resources/1peso-small.png")));
        bottomRightObject.setGoal(true);
        bottomRightObject.addMouseListener(toNextLevel);
        topLeftObject.setIcon(new ImageIcon(getClass().getResource("/resources/tuerca.png")));
        bottomLeftObject.setIcon(new ImageIcon(getClass().getResource("/resources/sol.png")));
        bottomLeftObject.setBounds(500, 400, 204, 166);
        window.repaint();
        voice.play();
    }
    
    public void setLevelFourEasy(){
        bottomRightObject.removeMouseListener(toNextLevel);
        bottomRightObject.setIcon(new ImageIcon(getClass().getResource("/resources/sol.png")));
        topRightObject.setIcon(new ImageIcon(getClass().getResource("/resources/corcholata2.png")));
        topLeftObject.setIcon(new ImageIcon(getClass().getResource("/resources/tuerca.png")));
        bottomLeftObject.setIcon(new ImageIcon(getClass().getResource("/resources/10pesos-big.png")));
        bottomLeftObject.setGoal(true);
        bottomLeftObject.addMouseListener(toNextLevel);
        topLeftObject.setIcon(new ImageIcon(getClass().getResource("/resources/tornillo.png")));
        window.repaint();
        voice.play();
    }
   
    public void setLevelFiveEasy(){
        topRightObject.removeMouseListener(toNextLevel);
        topRightObject.setIcon(new ImageIcon(getClass().getResource("/resources/tuerca2.png")));
        topLeftObject.setIcon(new ImageIcon(getClass().getResource("/resources/50-centavos.png")));
        topLeftObject.setGoal(true);
        topLeftObject.addMouseListener(toNextLevel);
        bottomRightObject.setIcon(new ImageIcon(getClass().getResource("/resources/corcholata2.png")));
        bottomLeftObject.setIcon(new ImageIcon(getClass().getResource("/resources/sol.png")));
        window.repaint();
        voice.play();
    }
    
    public void setLevelOneHard(){
        voice = java.applet.Applet.newAudioClip(getClass().getResource("/resources/seleccionaMonedaMex.wav"));
        voice.play();
        instructions.setIcon(new ImageIcon(getClass().getResource("/resources/coin_instruction_hard.png")));
        topRightObject.setIcon(new ImageIcon(getClass().getResource("/resources/2euros.png")));
        topRightObject.setBounds(800, 250, 230, 224);
        topLeftObject.setIcon(new ImageIcon(getClass().getResource("/resources/2pesos-big.png")));
        topLeftObject.setBounds(500, 250, 230, 230);
        topLeftObject.addMouseListener(toNextLevel);
        topLeftObject.setGoal(true);
        bottomLeftObject.setIcon(null);
        bottomRightObject.setIcon(null);
        currentLevel = 11;
        window.repaint();
    }
    
    public void setLevelTwoHard(){
        topRightObject.setIcon(new ImageIcon(getClass().getResource("/resources/10pesos-big.png")));
        topRightObject.addMouseListener(toNextLevel);
        topRightObject.setGoal(true);
        topLeftObject.removeMouseListener(toNextLevel);
        topLeftObject.setIcon(new ImageIcon(getClass().getResource("/resources/10centavos_euro.png")));
        window.repaint();
        voice.play();
    }
    
    public void setLevelThreeHard(){
        topRightObject.setIcon(new ImageIcon(getClass().getResource("/resources/5pesos-big.png")));
        topRightObject.setGoal(true);
        topLeftObject.setIcon(new ImageIcon(getClass().getResource("/resources/5soles.png")));
        window.repaint();
        voice.play();
    }
    
    public void setLevelFourHard(){
        topRightObject.removeMouseListener(toNextLevel);
        topRightObject.setIcon(new ImageIcon(getClass().getResource("/resources/1euro.png")));
        topLeftObject.addMouseListener(toNextLevel);
        topLeftObject.setGoal(true);
        topLeftObject.setIcon(new ImageIcon(getClass().getResource("/resources/1peso-big.png")));
        window.repaint();
        voice.play();
    }
    
    public void setLevelFiveHard(){
        topLeftObject.removeMouseListener(toNextLevel);
        topLeftObject.setIcon(new ImageIcon(getClass().getResource("/resources/50centavos-euro.png")));
        topRightObject.addMouseListener(toNextLevel);
        topRightObject.setGoal(true);
        topRightObject.setIcon(new ImageIcon(getClass().getResource("/resources/50centavos-big.png")));
        window.repaint();
        voice.play();
    }

    private void voiceFirst() {
        voice = java.applet.Applet.newAudioClip(getClass().getResource("/resources/seleccionaMoneda.wav"));
        voice.play();
    }
}
